package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.IntegralGoods;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.IntegralGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @Author: 曹朋飞
 * @Date: 2018/07/27 17:51
 * 积分商品管理类
 */
@RestController
public class IntegralGoodsController {
    
    @Autowired
    IntegralGoodsService integralGoodsService;


    /**
     * 分页查询
     * @param page 页码
     * @param size 每页条数
     */
    @GetMapping("/integralGoods/list/{page}/{size}/{draw}")
    public Response list(@PathVariable("page") Integer page,
                         @PathVariable("size") Integer size,
                         @PathVariable("draw") String draw){
        return integralGoodsService.selectAllByPage(page, size, draw);
    }

    /**
     * 添加积分商品
     * @param integralGoods
     * @return
     */
    @PostMapping("/integralGoods/save")
    public Response save(IntegralGoods integralGoods){
        return integralGoodsService.save(integralGoods);
    }


    /**
     * 修改
     * @param integralGoods
     * @return
     */
    @PostMapping("/integralGoods/update")
    public Response update(IntegralGoods integralGoods){
        return integralGoodsService.update(integralGoods);
    }


    /**
     * 查询积分商品详情
     * @param integralGoodsId:积分商品的id
     * @return
     */
    @GetMapping("/integralGoods/getIntegralGoodsById/{id}")
    public Response getIntegralGoodsById(@PathVariable("id")  String integralGoodsId){
        return integralGoodsService.getIntegralGoodsById(integralGoodsId);
    }

    /**
     * 删除
     * @param integralGoodsId:积分商品的id
     * @return
     */
    @DeleteMapping("/integralGoods/deleteById/{id}")
    public Response deleteById(@PathVariable("id")  String integralGoodsId){
        return integralGoodsService.deleteById(integralGoodsId);
    }

    /**
     * 批量删除
     * @param id:积分商品的id集合
     * @return
     */
    @DeleteMapping("/integralGoods/batchDeleteById/{id}")
    public Response batchDeleteById(@PathVariable("id")  String[] id){
        return integralGoodsService.batchDeleteById(id);
    }

    /**
     * 更改积分商品的状态
     * @param integralGoodsId:积分商品的id
     * @return
     */
    @GetMapping("/integralGoods/changeStatus/{id}")
    public Response changeStatus(@PathVariable("id")  String integralGoodsId){
        return integralGoodsService.changeStatus(integralGoodsId);
    }
    
    
}
